Skip to content
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

[Monitor][Codegen] Use generated TelemetryItem (as Envelope) #11280

Merged
merged 18 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ export import Base = require("./Base");
export import ContextTagKeys = require("./ContextTagKeys");
export import Data = require("./Data");
export import Domain = require("./Domain");
export import Envelope = require("./Envelope");
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import { Logger } from "@opentelemetry/api";
import { ConsoleLogger, LogLevel, ExportResult } from "@opentelemetry/core";
import { Envelope } from "../Declarations/Contracts";
import { ConnectionStringParser } from "../utils/connectionStringParser";
import { HttpSender, FileSystemPersist } from "../platform";
import { DEFAULT_EXPORTER_CONFIG, AzureExporterConfig } from "../config";
import { BaseExporter, TelemetryProcessor, PersistentStorage, Sender } from "../types";
import { isRetriable, BreezeResponse } from "../utils/breezeUtils";
import { ENV_CONNECTION_STRING, ENV_INSTRUMENTATION_KEY } from "../Declarations/Constants";
import { TelemetryItem as Envelope } from "../generated";

export abstract class AzureMonitorBaseExporter implements BaseExporter {
protected readonly _persister: PersistentStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ export class ApplicationInsightsClient extends ApplicationInsightsClientContext
}

/**
* This operation generates a model using an entire series, each point is detected with the same model.
* With this method, points before and after a certain point are used to determine whether it is an
* anomaly. The entire detection can give user an overall status of the time series.
* @param body Time series points and period if needed. Advanced model parameters can also be set in
* the request.
* This operation sends a sequence of telemetry events that will be monitored by Azure Monitor.
* @param body The list of telemetry events to track.
* @param options The options parameters.
*/
track(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface TelemetryItem {
/**
* Event date time when telemetry item was created. This is the wall clock time on the client when the event was generated. There is no guarantee that the client's time is accurate. This field must be formatted in UTC ISO 8601 format, with a trailing 'Z' character, as described publicly on https://en.wikipedia.org/wiki/ISO_8601#UTC. Note: the number of decimal seconds digits provided are variable (and unspecified). Consumers should handle this, i.e. managed code consumers should not use format 'O' for parsing as it specifies a fixed length. Example: 2009-06-15T13:45:30.0000000Z.
*/
time: Date;
time: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we really mean to make this a string and not a Date? Usually Date is easier to work with.

Copy link
Contributor Author

@markwolff markwolff Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Have you gotten dates to be cross-lang interoperable in other client SDKs? Maybe the mapper/serializer could handle mapping Date to string?

https://github.com/Azure/azure-rest-api-specs/blob/27cc07ddd294d98e05cb301e07a72378df9f87e8/specification/applicationinsights/data-plane/Monitor.Exporters/preview/2020-09-15_Preview/swagger.json#L850-L853

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it work if you do something like this?

"startTime": {
  "type": "string",
  "format": "date-time",
  "description": "The time when an indexer should start running."
}

/**
* Sampling rate used in application. This telemetry item represents 1 / sampleRate actual telemetry items.
*/
Expand Down Expand Up @@ -65,9 +65,13 @@ export interface MonitorBase {
*/
export interface MonitorDomain {
/**
* Ignored value.
* Describes unknown properties. The value of an unknown property can be of "any" type.
*/
test?: string;
[property: string]: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means anything that mixes in with MonitorDomain isn't type-checked by TS as all properties are valid. It would be best to avoid this if possible, since it's easy to make typos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can go away once autorest supports oneOf polymophism. Until then, this is meant to be a temporary workaround

/**
* Schema version
*/
version: number;
}

/**
Expand Down Expand Up @@ -205,10 +209,6 @@ export interface StackFrame {
* Instances of AvailabilityData represent the result of executing an availability test.
*/
export type AvailabilityData = MonitorDomain & {
/**
* Schema version
*/
version: number;
/**
* Identifier of a test run. Use it to correlate steps of test run and telemetry generated by the service.
*/
Expand Down Expand Up @@ -247,10 +247,6 @@ export type AvailabilityData = MonitorDomain & {
* Instances of Event represent structured event records that can be grouped and searched by their properties. Event data item also creates a metric of event count by name.
*/
export type TelemetryEventData = MonitorDomain & {
/**
* Schema version
*/
version: number;
/**
* Event name. Keep it low cardinality to allow proper grouping and useful metrics.
*/
Expand All @@ -269,14 +265,10 @@ export type TelemetryEventData = MonitorDomain & {
* An instance of Exception represents a handled or unhandled exception that occurred during execution of the monitored application.
*/
export type TelemetryExceptionData = MonitorDomain & {
/**
* Schema version
*/
version: number;
/**
* Exception chain - list of inner exceptions.
*/
exceptions?: TelemetryExceptionDetails[];
exceptions: TelemetryExceptionDetails[];
/**
* Severity level. Mostly used to indicate exception severity level when it is reported by logging library.
*/
Expand All @@ -296,13 +288,9 @@ export type TelemetryExceptionData = MonitorDomain & {
};

/**
* Instances of Message represent printf-like trace statements that are text-searched. Log4Net, NLog and other text-based log file entries are translated into intances of this type. The message does not have measurements.
* Instances of Message represent printf-like trace statements that are text-searched. Log4Net, NLog and other text-based log file entries are translated into instances of this type. The message does not have measurements.
*/
export type MessageData = MonitorDomain & {
/**
* Schema version
*/
version: number;
/**
* Trace message
*/
Expand All @@ -325,10 +313,6 @@ export type MessageData = MonitorDomain & {
* An instance of the Metric item is a list of measurements (single data points) and/or aggregations.
*/
export type MetricsData = MonitorDomain & {
/**
* Schema version
*/
version: number;
/**
* List of metrics. Only one metric in the list is currently supported by Application Insights storage. If multiple data points were sent only the first one will be used.
*/
Expand All @@ -343,10 +327,6 @@ export type MetricsData = MonitorDomain & {
* An instance of PageView represents a generic action on a page like a button click. It is also the base type for PageView.
*/
export type PageViewData = MonitorDomain & {
/**
* Schema version
*/
version: number;
/**
* Identifier of a page view instance. Used for correlation between page view and other telemetry items.
*/
Expand Down Expand Up @@ -381,10 +361,6 @@ export type PageViewData = MonitorDomain & {
* An instance of PageViewPerf represents: a page view with no performance data, a page view with performance data, or just the performance data of an earlier page request.
*/
export type PageViewPerfData = MonitorDomain & {
/**
* Schema version
*/
version: number;
/**
* Identifier of a page view instance. Used for correlation between page view and other telemetry items.
*/
Expand Down Expand Up @@ -435,10 +411,6 @@ export type PageViewPerfData = MonitorDomain & {
* An instance of Remote Dependency represents an interaction of the monitored component with a remote component/service like SQL or an HTTP endpoint.
*/
export type RemoteDependencyData = MonitorDomain & {
/**
* Schema version
*/
version: number;
/**
* Identifier of a dependency call instance. Used for correlation with the request telemetry item corresponding to this dependency call.
*/
Expand All @@ -452,7 +424,7 @@ export type RemoteDependencyData = MonitorDomain & {
*/
resultCode?: string;
/**
* Command initiated by this dependency call. Examples are SQL statement and HTTP URL's with all query parameters.
* Command initiated by this dependency call. Examples are SQL statement and HTTP URL with all query parameters.
*/
data?: string;
/**
Expand All @@ -468,7 +440,7 @@ export type RemoteDependencyData = MonitorDomain & {
*/
duration: string;
/**
* Indication of successfull or unsuccessfull call.
* Indication of successful or unsuccessful call.
*/
success?: boolean;
/**
Expand All @@ -482,13 +454,9 @@ export type RemoteDependencyData = MonitorDomain & {
};

/**
* An instance of PageView represents a generic action on a page like a button click. It is also the base type for PageView.
* An instance of Request represents completion of an external request to the application to do work and contains a summary of that request execution and the results.
*/
export type RequestData = MonitorDomain & {
/**
* Schema version
*/
version: number;
/**
* Identifier of a request call instance. Used for correlation between request and other telemetry items.
*/
Expand All @@ -502,7 +470,7 @@ export type RequestData = MonitorDomain & {
*/
duration: string;
/**
* Indication of successfull or unsuccessfull call.
* Indication of successful or unsuccessful call.
*/
success: boolean;
/**
Expand Down
Loading