-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[Monitor OpenTelemetry] Add Ability to Config Views
#36684
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,7 @@ const options: AzureMonitorOpenTelemetryOptions = { | |
| resource: resource, | ||
| logRecordProcessors: [], | ||
| spanProcessors: [], | ||
| views: [], | ||
| }; | ||
| useAzureMonitor(options); | ||
| ``` | ||
|
|
@@ -159,6 +160,11 @@ useAzureMonitor(options); | |
| <td>Array of span processors to register to the global tracer provider. </td> | ||
| <td></td> | ||
| </tr> | ||
| <tr> | ||
| <td><code>views</code></td> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the documentation for the configure opentelemetry needs to be updated for this change?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it will need to be, but waiting on PR review & API review. |
||
| <td>Array of metric views to register to the global meter provider.</td> | ||
| <td></td> | ||
| </tr> | ||
| <tr> | ||
| <td><code>enableTraceBasedSamplingForLogs</code></td> | ||
| <td>Enable log sampling based on trace.</td> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import { metrics, trace } from "@opentelemetry/api"; | |
| import { logs } from "@opentelemetry/api-logs"; | ||
| import type { AzureMonitorOpenTelemetryOptions } from "../../../src/index.js"; | ||
| import { useAzureMonitor, shutdownAzureMonitor, _getSdkInstance } from "../../../src/index.js"; | ||
| import type { MeterProvider } from "@opentelemetry/sdk-metrics"; | ||
| import type { MeterProvider, ViewOptions } from "@opentelemetry/sdk-metrics"; | ||
| import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics"; | ||
| import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http"; | ||
| import type { StatsbeatEnvironmentConfig } from "../../../src/types.js"; | ||
|
|
@@ -155,6 +155,20 @@ describe("Main functions", () => { | |
| expect(spyonEmit).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("should add custom metric views", () => { | ||
| const customView: ViewOptions = { meterName: "custom-meter" }; | ||
| const config: AzureMonitorOpenTelemetryOptions = { | ||
| azureMonitorExporterOptions: { | ||
| connectionString: "InstrumentationKey=00000000-0000-0000-0000-000000000000", | ||
| }, | ||
| views: [customView], | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is possible to have multiple custom views right? In that case, does config have the ability to process them as a list of views?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we just pass this to the NodeSDKConfiguration in OpenTelemetry which takes a |
||
| }; | ||
| useAzureMonitor(config); | ||
| const meterConfig = (_getSdkInstance() as any)?._meterProviderConfig; | ||
| expect(meterConfig).toBeDefined(); | ||
| expect(meterConfig?.views).toContain(customView); | ||
| }); | ||
|
|
||
| it("should set statsbeat features", () => { | ||
| const config: AzureMonitorOpenTelemetryOptions = { | ||
| azureMonitorExporterOptions: { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.