Skip to content

Commit ff84513

Browse files
authored
feat: Add instrumentation for @mistralai/mistralai (#1730)
Adds instrumentation for the mistral SDK (`@mistralai/mistralai`): - Agents.complete - Agents.stream - Chat.complete - Chat.stream - Fim.complete - Fim.stream - Embeddings.create Notes: - Adds comprehensive E2E test suite with canary and different versions Resolves #1688
1 parent 7d4f4c4 commit ff84513

File tree

61 files changed

+8673
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+8673
-84
lines changed

.agents/skills/instrumentation/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Map the change before editing:
3535
- Promise/stream behavior must be preserved. Patches need to keep subclass/helper semantics intact.
3636
- Contain instrumentation failures. Extraction/logging bugs should be logged or ignored as appropriate, but must not break the user call path.
3737
- Log only the useful surface. Prefer narrow, stable payloads over dumping full request/response objects; exclude redundant or overly large data when possible.
38+
- We want to limit our instrumentation to operations that are relevant for AI generations and operations (LLMs, embeddings, media generation, ...). Things like creating entities on platforms (CRUD for Workflows of Agent entities) is irrelevant to us.
3839
- When building instrumentation, we should always have a vendored type/interface for what we are wrapping. The type or interface should not be larger than what is relevant to the instrumentation. The type or interface should be used for typing tracing channels and also should be used to assert the type on whatever is passed into wrappers as soon as the wrapper has verified that the passed in value is plausibly what should be wrapped.
3940

4041
## Process

.env.example

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
2-
BRAINTRUST_API_KEY=your_braintrust_api_key
3-
OPENAI_API_KEY=your_openai_api_key
4-
ANTHROPIC_API_KEY=your_anthropic_key
1+
BRAINTRUST_API_KEY=
2+
OPENAI_API_KEY=
3+
ANTHROPIC_API_KEY=
4+
GEMINI_API_KEY=
5+
OPENROUTER_API_KEY=
6+
MISTRAL_API_KEY=

.github/workflows/e2e-canary.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
3838
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
3939
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
40+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
4041
run: pnpm test:e2e:canary
4142
- name: Create or update nightly canary issue
4243
if: ${{ failure() && github.event_name == 'schedule' }}

.github/workflows/integration-tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
3131
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
3232
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
33+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
3334
steps:
3435
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
3536
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
@@ -57,6 +58,7 @@ jobs:
5758
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
5859
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
5960
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
61+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
6062
steps:
6163
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
6264
- uses: denoland/setup-deno@ff4860f9d7236f320afa0f82b7e6457384805d05 # v2.0.4
@@ -105,6 +107,7 @@ jobs:
105107
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
106108
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
107109
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
110+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
108111
steps:
109112
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
110113
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"typescript.tsdk": "js/node_modules/typescript/lib",
3-
"typescript.enablePromptUseWorkspaceTsdk": false
2+
"js/ts.tsdk.promptToUseWorkspaceVersion": false,
3+
"js/ts.tsdk.path": "js/node_modules/typescript/lib"
44
}

e2e/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Non-hermetic scenarios require provider credentials in addition to the mock Brai
116116
- `ANTHROPIC_API_KEY`
117117
- `GEMINI_API_KEY` or `GOOGLE_API_KEY`
118118
- `OPENROUTER_API_KEY`
119+
- `MISTRAL_API_KEY`
119120

120121
`claude-agent-sdk-instrumentation` also uses `ANTHROPIC_API_KEY`, because it runs the real Claude Agent SDK against Anthropic in the same style as the existing live Anthropic wrapper coverage.
121122

e2e/config/pr-comment-scenarios.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@
3333
{ "variantKey": "google-genai-v1460", "label": "v1.46.0" }
3434
]
3535
},
36+
{
37+
"scenarioDirName": "mistral-instrumentation",
38+
"label": "Mistral Instrumentation",
39+
"metadataScenario": "mistral-instrumentation",
40+
"variants": [
41+
{ "variantKey": "mistral-v1-3-4", "label": "v1.3.4" },
42+
{ "variantKey": "mistral-v1-10-0", "label": "v1.10.0" },
43+
{ "variantKey": "mistral-v1-14-1", "label": "v1.14.1" },
44+
{ "variantKey": "mistral-v1-15-1", "label": "v1.15.1" },
45+
{ "variantKey": "mistral-v1", "label": "latest v1" },
46+
{ "variantKey": "mistral-v2", "label": "latest v2" }
47+
]
48+
},
3649
{
3750
"scenarioDirName": "openrouter-instrumentation",
3851
"label": "OpenRouter Instrumentation",

e2e/helpers/scenario-installer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const INSTALL_SECRET_ENV_VARS = [
2626
"GH_TOKEN",
2727
"OPENAI_API_KEY",
2828
"OPENROUTER_API_KEY",
29+
"MISTRAL_API_KEY",
2930
] as const;
3031

3132
const cleanupDirs = new Set<string>();

0 commit comments

Comments
 (0)