-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(instrumentation): add fw metrics #187
base: main
Are you sure you want to change the base?
Conversation
89064aa
to
5de3232
Compare
const metricExporter = new OTLPMetricExporter({ | ||
url: "https://bee-collector.apps.fmaas-backend.fmaas.res.ibm.com/v1/metrics", | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will likely need some better domain that is stable. @matoushavlena
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with @GALLLASMILAN. He is going to lead the next actions required for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will switch the URL to https://bee-telemetry.res.ibm.com/v1/metrics when it's prepared.
package.json
Outdated
"@opentelemetry/exporter-metrics-otlp-http": "^0.54.2", | ||
"@opentelemetry/resources": "^1.27.0", | ||
"@opentelemetry/sdk-metrics": "^1.27.0", | ||
"@opentelemetry/sdk-node": "^0.54.2", | ||
"@opentelemetry/semantic-conventions": "^1.27.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to specify the metrics deps directly? Following should work
import { metrics } from "@opentelemetry/sdk-node"
README.md
Outdated
@@ -152,6 +152,10 @@ This project and everyone participating in it are governed by the [Code of Condu | |||
|
|||
All content in these repositories including code has been provided by IBM under the associated open source software license and IBM is under no obligation to provide enhancements, updates, or support. IBM developers produced this code as an open source project (not as an IBM product), and IBM makes no assertions as to the level of quality nor security, and will not be maintaining this code going forward. | |||
|
|||
## Telemetry | |||
|
|||
Some metrics are collected by default. See the [Native Telemetry](./docs/native-telemetry.md) for more detail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use absolute path + run yarn docs:build
afterward.
package.json
Outdated
"test:unit": "BEE_FRAMEWORK_INSTRUMENTATION_METRICS_DISABLED=true vitest run src", | ||
"test:unit:watch": "BEE_FRAMEWORK_INSTRUMENTATION_METRICS_DISABLED=true vitest run src", | ||
"test:e2e": "BEE_FRAMEWORK_INSTRUMENTATION_METRICS_DISABLED=true vitest run tests/e2e", | ||
"test:e2e:watch": "BEE_FRAMEWORK_INSTRUMENTATION_METRICS_DISABLED=true vitest watch tests/e2e", | ||
"test:all": "yarn test:unit && yarn test:e2e && yarn test:examples", | ||
"test:examples": "vitest --config ./examples/vitest.examples.config.ts run tests/examples", | ||
"test:examples:watch": "vitest --config ./examples/vitest.examples.config.ts watch tests/examples", | ||
"test:examples": "BEE_FRAMEWORK_INSTRUMENTATION_METRICS_DISABLED=true vitest --config ./examples/vitest.examples.config.ts run tests/examples", | ||
"test:examples:watch": "BEE_FRAMEWORK_INSTRUMENTATION_METRICS_DISABLED=true vitest --config ./examples/vitest.examples.config.ts watch tests/examples", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add such variable to .env.test
(just create it, it is going to be automatically used: see tests/setup.ts
)
src/instrumentation/config.ts
Outdated
@@ -18,6 +18,9 @@ import { parseEnv } from "@/internals/env.js"; | |||
import { z } from "zod"; | |||
|
|||
export const INSTRUMENTATION_ENABLED = parseEnv.asBoolean("BEE_FRAMEWORK_INSTRUMENTATION_ENABLED"); | |||
export const INSTRUMENTATION_METRICS_ENABLED = !parseEnv.asBoolean( | |||
"BEE_FRAMEWORK_INSTRUMENTATION_METRICS_DISABLED", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we not switch the flag to _ENABLED
and set the default to true
?
// send metrics to the public collector | ||
emitter.match( | ||
(event) => event.path === `${basePath}.run.${finishEventName}`, | ||
async () => await metricReader.forceFlush(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIP: metricReader.forceFlush.bind(metricReader)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, this inside forceFlush
will always correctly refer to metricReader
, so bind() is not required.
Signed-off-by: GALLLASMILAN <[email protected]>
Signed-off-by: GALLLASMILAN <[email protected]>
5de3232
to
cbfaa9b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding this document to the documentation sidebar. (docs/_sidebar.md
)
docs/native-telemetry.md
Outdated
|
||
We understand that not all users want to send telemetry data. You can easily disable this feature by setting an environment variable: | ||
|
||
```bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't there support for ```env ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen the ```env yet, I will remove the bash
part and the markdown will highlight it correctly.
Signed-off-by: GALLLASMILAN <[email protected]>
Description
I added the new custom middleware, that collects
module_usage
statistics with data about os, version etc. This middleware is enabled by default and sends data about the (agent, llm, tool) entities.Data are automatically sent via the open telemetry SDK that is part of the framework right now, but it's configured only for metrics. I use PeriodicMetric reader, but I need to push the metrics when each run ends. Otherwise, I would drop a lot of metrics because the runtime does not wait for the SDK pushing.
This default telemetry can be disabled via the
BEE_FRAMEWORK_INSTRUMENTATION_METRICS_DISABLED
environment variable. See the new./docs/docs/native-telemetry.md
file for more info.Checklist
yarn lint
oryarn lint:fix
yarn format
oryarn format:fix
yarn test:unit
yarn test:e2e