Skip to content

Commit

Permalink
[Azure Monitor OpenTelemetry] Update Quickpulse transmission time (Az…
Browse files Browse the repository at this point in the history
…ure#28411)

### Packages impacted by this PR
@azure/monitor-opentelemetry
  • Loading branch information
hectorhdzg authored Jan 30, 2024
1 parent c7301ab commit d44974c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
PostOptionalParams,
PostResponse,
} from "../../../generated";
import { resourceMetricsToQuickpulseDataPoint } from "../utils";
import { getTransmissionTime, resourceMetricsToQuickpulseDataPoint } from "../utils";

/**
* Quickpulse Metric Exporter.
Expand Down Expand Up @@ -62,7 +62,7 @@ export class QuickpulseMetricExporter implements PushMetricExporter {
this.baseMonitoringDataPoint,
this.getDocumentsFn(),
),
xMsQpsTransmissionTime: Date.now(),
xMsQpsTransmissionTime: getTransmissionTime(),
};
// Supress tracing until OpenTelemetry Metrics SDK support it
await context.with(suppressTracing(context.active()), async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
getLogDocument,
getSdkVersion,
getSpanDocument,
getTransmissionTime,
} from "./utils";
import { QuickpulseMetricExporter } from "./export/exporter";
import { QuickpulseSender } from "./export/sender";
Expand Down Expand Up @@ -150,7 +151,7 @@ export class LiveMetrics {
// If not collecting, Ping
try {
let params: PingOptionalParams = {
xMsQpsTransmissionTime: Date.now(),
xMsQpsTransmissionTime: getTransmissionTime(),
monitoringDataPoint: this.baseMonitoringDataPoint,
};
await context.with(suppressTracing(context.active()), async () => {
Expand Down
13 changes: 13 additions & 0 deletions sdk/monitor/monitor-opentelemetry/src/metrics/quickpulse/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,16 @@ function getUrl(attributes: Attributes): string {
}
return "";
}

/**
* @description UTC time the request was made. Expressed as the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight on January 1, 0001. This is used for clock skew calculations, so the value can never be stale (cached).
*
* @example
* 8/5/2020 10:15:00 PM UTC => 637322625000000000
* 8/5/2020 10:15:01 PM UTC => 637322625010000000
*
* @returns {number}
*/
export function getTransmissionTime(): number {
return (Date.now() + 62135596800000) * 10000;
}

0 comments on commit d44974c

Please sign in to comment.