-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a `@elastic/opentelemetry-instrumentation-openai` instrumentation.
- Loading branch information
Showing
68 changed files
with
11,103 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Release a tagged version of the '@elastic/opentelemetry-instrumentation-openai' package. | ||
name: release-instrumentation-openai | ||
|
||
on: | ||
push: | ||
tags: | ||
- instrumentation-openai-v*.*.* | ||
|
||
# 'id-token' perm needed for npm publishing with provenance (see | ||
# https://docs.npmjs.com/generating-provenance-statements#example-github-actions-workflow) | ||
permissions: | ||
contents: write | ||
pull-requests: read | ||
id-token: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
env: | ||
PKGDIR: packages/instrumentation-openai | ||
PKGNAME: "@elastic/opentelemetry-instrumentation-openai" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'v18.20.4' | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: npm publish | ||
working-directory: $PKGDIR | ||
run: npm publish | ||
env: | ||
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: GitHub release | ||
run: | | ||
npm ci # need top-level devDeps for github-release.sh script | ||
./scripts/github-release.sh "$PKGDIR" "${{ github.ref_name }}" | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
|
||
- name: Notify in Slack | ||
# Only notify on failure, because on success the published GitHub | ||
# Release will result in a notification from the GitHub Slack app | ||
# (assuming '/github subscribe elastic/elastic-otel-node'). | ||
if: ${{ failure() }} | ||
uses: elastic/oblt-actions/slack/[email protected] | ||
with: | ||
bot-token: ${{ secrets.SLACK_BOT_TOKEN }} | ||
channel-id: "#apm-agent-node" | ||
message: '[${{ github.repository }}] Release `${{ env.PKGNAME }}` *${{ github.ref_name }}*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: test-instrumentation-openai | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'packages/instrumentation-openai/**' | ||
- '.github/workflows/test-instrumentation-openai.yml' | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'packages/instrumentation-openai/**' | ||
- '.github/workflows/test-instrumentation-openai.yml' | ||
|
||
# Cancel jobs running for old commits on a PR. Allow concurrent runs on 'main'. | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
unit-test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: | ||
- '22' | ||
- '20' | ||
- '18' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- run: npm ci | ||
working-directory: packages/instrumentation-openai | ||
- run: npm run compile | ||
working-directory: packages/instrumentation-openai | ||
- run: npm test | ||
working-directory: packages/instrumentation-openai | ||
|
||
# This runs the unit tests against a number of 'openai' versions in the | ||
# supported range. | ||
test-all-versions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- run: npm install | ||
working-directory: packages/instrumentation-openai | ||
- run: npm run compile | ||
working-directory: packages/instrumentation-openai | ||
- run: npm run test-all-versions | ||
working-directory: packages/instrumentation-openai | ||
|
||
integration-test: | ||
runs-on: ubuntu-latest | ||
services: | ||
ollama: | ||
# A light fork of Ollama to float some in-progress contributions related | ||
# to more closely matching OpenAI behavior. | ||
image: ghcr.io/elastic/ollama/ollama:testing | ||
ports: | ||
- 11434:11434 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- name: Pull Ollama models | ||
run: | | ||
source packages/instrumentation-openai/ollama.env | ||
curl -s http://localhost:11434/api/pull -d "{\"model\": \"$TEST_MODEL_TOOLS\"}" | ||
curl -s http://localhost:11434/api/pull -d "{\"model\": \"$TEST_MODEL_EMBEDDINGS\"}" | ||
curl -s http://localhost:11434/api/tags | jq | ||
# Dump Ollama container logs if it doesn't appear to be working. | ||
curl -fsS http://localhost:11434/ || docker logs $(docker ps -q) | ||
- run: npm install | ||
working-directory: packages/instrumentation-openai | ||
- run: npm run compile | ||
working-directory: packages/instrumentation-openai | ||
- name: Integration tests | ||
run: | | ||
set -a; source ./ollama.env | ||
npm run test:integration | ||
working-directory: packages/instrumentation-openai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ packages will use a prefix (the basename of the npm package name). For example, | |
| ----------------------------- | ------------------- | -------- | | ||
| `@elastic/opentelemetry-node` | `v*` | v1.0.0 | | ||
| `@elastic/mockotlpserver` | `mockotlpserver-v*` | mockotlpserver-v0.2.0 | | ||
| `@elastic/opentelemetry-instrumentation-openai` | `instrumentation-openai-v*` | instrumentation-openai-v0.3.0 | | ||
|
||
|
||
## How to release `@elastic/opentelemetry-node` | ||
|
@@ -40,26 +41,32 @@ Assuming "x.y.z" is the release verison: | |
https://github.com/elastic/elastic-otel-node/actions/workflows/release.yml | ||
## How to release `@elastic/mockotlpserver` | ||
## How to release other packages | ||
Assuming "x.y.z" is the release verison: | ||
Assuming: | ||
- **VERSION="x.y.z"** is the release version and | ||
- **PKGSUBDIR="instrumentation-openai"** is the package being released. | ||
(Note that the PKGSUBDIR, the directory under "packages/" is *not necessarily* | ||
the basename of the npm package.) | ||
1. Choose the appropriate version number according to semver. | ||
2. Create a PR with these changes: | ||
- Bump the "version" in "packages/mockotlpserver/package.json". | ||
- Run `npm install` in "packages/mockotlpserver/" to update "packages/mockotlpserver/package-lock.json". | ||
- Update "packages/mockotlpserver/CHANGELOG.md" as necessary. | ||
- Name the PR something like "release @elastic/[email protected]". | ||
- Bump the "version" in "packages/$PKGSUBDIR/package.json". | ||
- Run `npm install` in "packages/$PKGSUBDIR/" to update "packages/$PKGSUBDIR/package-lock.json". | ||
- Update "packages/$PKGSUBDIR/CHANGELOG.md" as necessary. | ||
- Name the PR something like "release $PKGSUBDIR x.y.z". | ||
3. Get the PR approved and merged. | ||
4. Working on the elastic repo (not a fork), tag the commit as follows: | ||
``` | ||
git tag mockotlpserver-vx.y.z | ||
git push origin mockotlpserver-vx.y.z | ||
git tag $PKGSUBDIR-vx.y.z | ||
git push origin $PKGSUBDIR-vx.y.z | ||
``` | ||
The GitHub Actions "release-mockotlpserver" workflow will handle the release | ||
steps -- including the `npm publish`. See the appropriate run at: | ||
https://github.com/elastic/elastic-otel-node/actions/workflows/release-mockotlpserver.yml | ||
The GitHub Actions "release-$PKGSUBDIR" workflow will handle the release | ||
steps -- including the `npm publish`. See the appropriate run at: | ||
https://github.com/elastic/elastic-otel-node/actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.