-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
007acb0
commit 1d94af3
Showing
42 changed files
with
1,085 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as ec2Plugin from './segments/plugins/ec2_plugin'; | ||
import * as ecsPlugin from './segments/plugins/ecs_plugin'; | ||
import * as elasticBeanstalkPlugin from './segments/plugins/elastic_beanstalk_plugin'; | ||
import * as segmentUtils from './segments/segment_utils'; | ||
import * as utils from './utils'; | ||
import * as middleware from './middleware/mw_utils'; | ||
import Segment = require('./segments/segment'); | ||
import Subsegment = require('./segments/attributes/subsegment'); | ||
import sqlData = require('./database/sql_data'); | ||
|
||
export namespace plugins { | ||
const EC2Plugin: typeof ec2Plugin; | ||
const ECSPlugin: typeof ecsPlugin; | ||
const ElasticBeanstalkPlugin: typeof elasticBeanstalkPlugin; | ||
|
||
type EC2Plugin = typeof ec2Plugin; | ||
type ECSPlugin = typeof ecsPlugin; | ||
type ElasticBeanstalkPlugin = typeof elasticBeanstalkPlugin; | ||
|
||
type EC2Metadata = ec2Plugin.EC2Metadata; | ||
type ECSMetadata = ecsPlugin.ECSMetadata; | ||
type ElasticBeanstalkMetadata = elasticBeanstalkPlugin.ElasticBeanstalkMetadata; | ||
|
||
type Plugin = EC2Plugin | ECSPlugin | ElasticBeanstalkPlugin; | ||
} | ||
|
||
export function config(plugins: plugins.Plugin[]): void; | ||
|
||
export { appendAWSWhitelist, setAWSWhitelist } from './segments/attributes/aws'; | ||
|
||
export { setStreamingThreshold } from './segments/segment_utils'; | ||
|
||
export { setLogger, getLogger, Logger } from './logger'; | ||
|
||
export { setDaemonAddress } from './daemon_config' | ||
|
||
export { captureAsyncFunc, captureCallbackFunc, captureFunc } from './capture' | ||
|
||
export { captureAWS, captureAWSClient } from './patchers/aws_p'; | ||
|
||
export { captureHTTPs, captureHTTPsGlobal } from './patchers/http_p'; | ||
|
||
export { capturePromise } from './patchers/promise_p'; | ||
|
||
export { utils } | ||
|
||
export namespace database { | ||
const SqlData: typeof sqlData; | ||
type SqlData = sqlData; | ||
} | ||
|
||
export { middleware } | ||
|
||
export { | ||
getNamespace, | ||
resolveSegment, | ||
getSegment, | ||
setSegment, | ||
isAutomaticMode, | ||
enableAutomaticMode, | ||
enableManualMode, | ||
setContextMissingStrategy | ||
} from './context_utils'; | ||
|
||
export { | ||
Segment, | ||
Subsegment, | ||
segmentUtils as SegmentUtils | ||
} | ||
|
||
export type SegmentLike = Segment | Subsegment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Segment = require('./segments/segment'); | ||
import Subsegment = require('./segments/attributes/subsegment'); | ||
|
||
export function captureFunc<T>(name: string, fcn: (subsegment?: Subsegment) => T, parent?: Segment | Subsegment): T; | ||
|
||
export function captureAsyncFunc<T>( | ||
name: string, | ||
fcn: (subsegment?: Subsegment) => T, | ||
parent?: Segment | Subsegment | ||
): T; | ||
|
||
export function captureCallbackFunc<S extends any[], T>( | ||
name: string, | ||
fcn: (...args: S) => T, | ||
parent?: Segment | Subsegment | ||
): (...args: S) => T; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Namespace } from 'continuation-local-storage'; | ||
import Segment = require('./segments/segment'); | ||
import Subsegment = require('./segments/attributes/subsegment'); | ||
|
||
export function getNamespace(): Namespace; | ||
|
||
export function resolveSegment(segment: Segment | Subsegment): Segment | Subsegment | undefined; | ||
|
||
export function getSegment(): Segment | Subsegment | undefined; | ||
|
||
export function setSegment(segment: Segment | Subsegment): void; | ||
|
||
export function isAutomaticMode(): boolean; | ||
|
||
export function enableAutomaticMode(): void; | ||
|
||
export function enableManualMode(): void; | ||
|
||
export type ContextMissingStrategy = 'LOG_ERROR' | 'RUNTIME_ERROR' | ((msg: string) => void); | ||
|
||
export function setContextMissingStrategy(strategy: ContextMissingStrategy): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function setDaemonAddress(address: string): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
declare class SqlData { | ||
database_version?: string; | ||
driver_version?: string; | ||
preparation?: string; | ||
url?: string; | ||
user?: string; | ||
|
||
constructor(databaseVer?: string, driverVer?: string, user?: string, url?: string, queryType?: string); | ||
} | ||
|
||
export = SqlData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './aws-xray'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface Logger { | ||
debug(...args: any[]): any; | ||
info(...args: any[]): any; | ||
warn(...args: any[]): any; | ||
error(...args: any[]): any; | ||
} | ||
|
||
export function setLogger(logObj: Logger): void; | ||
|
||
export function getLogger(): Logger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as http from 'http'; | ||
|
||
declare class IncomingRequestData { | ||
request: { [key: string]: any }; | ||
|
||
constructor(req: http.IncomingMessage); | ||
|
||
close(res: http.ServerResponse): void; | ||
} | ||
|
||
export = IncomingRequestData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as http from 'http'; | ||
import Segment = require('../segments/segment'); | ||
import IncomingRequestData = require('./incoming_request_data'); | ||
|
||
export const defaultName: string | undefined; | ||
|
||
export const dynamicNaming: boolean; | ||
|
||
export const hostPattern: string | null; | ||
|
||
export function enableDynamicNaming(hostPattern?: string): void; | ||
|
||
export function processHeaders(req?: Partial<Pick<http.IncomingMessage, 'headers'>>): { [key: string]: string }; | ||
|
||
export function resolveName(hostHeader?: string): string; | ||
|
||
export function resolveSampling(amznTraceHeader: object, segment: Segment, res: http.ServerResponse): void; | ||
|
||
export function setDefaultName(name: string): void; | ||
|
||
export function disableCentralizedSampling(): void; | ||
|
||
export interface BaseRuleConfig { | ||
http_method: string; | ||
url_path: string; | ||
fixed_target: number; | ||
rate: number; | ||
description?: string; | ||
} | ||
|
||
export interface RuleConfigV1 extends BaseRuleConfig { | ||
service_name: string; | ||
} | ||
|
||
export interface RuleConfigV2 extends BaseRuleConfig { | ||
host: string; | ||
} | ||
|
||
export type RuleConfig = RuleConfigV1 | RuleConfigV2; | ||
|
||
export interface DefaultRuleConfig { | ||
fixed_target: number; | ||
rate: number; | ||
} | ||
|
||
export interface RulesConfig { | ||
version: number; | ||
default: DefaultRuleConfig; | ||
rules?: RuleConfig[]; | ||
} | ||
|
||
export function setSamplingRules(source: string | RulesConfig): void; | ||
|
||
export { | ||
IncomingRequestData | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as AWS from 'aws-sdk'; | ||
import Segment = require('../segments/segment'); | ||
import Subsegment = require('../segments/attributes/subsegment'); | ||
|
||
export type Callback<D> = (err: AWS.AWSError | undefined, data: D) => void; | ||
|
||
export interface AWSRequestMethod<P, D> { | ||
(params: P, callback?: Callback<D>): AWS.Request<D, AWS.AWSError>; | ||
(callback?: Callback<D>): AWS.Request<D, AWS.AWSError>; | ||
} | ||
|
||
export type PatchedAWSRequestMethod<P, D> = AWSRequestMethod<P & { XRaySegment?: Segment | Subsegment }, D>; | ||
|
||
export type PatchedAWSClient<T extends AWS.Service> = { | ||
[K in keyof T]: T[K] extends AWSRequestMethod<infer P, infer D> | ||
? PatchedAWSRequestMethod<P, D> | ||
: T[K] | ||
}; | ||
|
||
export interface AWSClientConstructor<P, T extends typeof AWS.Service> { | ||
new(params?: P): InstanceType<T>; | ||
} | ||
|
||
export interface PatchedAWSClientConstructor<P, T extends typeof AWS.Service> { | ||
new(params?: P): PatchedAWSClient<InstanceType<T>>; | ||
} | ||
|
||
export type PatchedAWS<T = typeof AWS> = { | ||
[K in keyof T]: T[K] extends typeof AWS.Service | ||
? (T[K] extends AWSClientConstructor<infer P, T[K]> | ||
? PatchedAWSClientConstructor<P, T[K]> | ||
: T[K]) | ||
: T[K]; | ||
}; | ||
|
||
export function captureAWS(awssdk: typeof AWS): PatchedAWS; | ||
|
||
export function captureAWSClient<T extends AWS.Service>(service: T): PatchedAWSClient<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as http from 'http'; | ||
import * as https from 'https'; | ||
|
||
export function captureHTTPs<T extends typeof http | typeof https>(mod: T, downstreamXRayEnabled: boolean): T; | ||
|
||
export function captureHTTPsGlobal(mod: typeof https | typeof http, downstreamXRayEnabled: boolean): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const capturePromise: { | ||
(): void; | ||
patchThirdPartyPromise(Promise: any): void; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as AWS from "aws-sdk"; | ||
|
||
declare class Aws { | ||
constructor(res: AWS.Response<any, any>, serviceName: string); | ||
|
||
addData(data: any): void; | ||
} | ||
|
||
declare namespace Aws { | ||
function setAWSWhitelist(source: string | object): void; | ||
|
||
function appendAWSWhitelist(source: string | object): void; | ||
} | ||
|
||
export = Aws; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import * as http from 'http'; | ||
|
||
declare class Subsegment { | ||
id: string; | ||
name: string; | ||
start_time: number; | ||
in_progress: boolean; | ||
counter: number; | ||
|
||
constructor(name: string); | ||
|
||
addNewSubsegment(name: string): Subsegment; | ||
|
||
addSubsegment(subsegment: Subsegment): void; | ||
|
||
removeSubsegment(subsegment: Subsegment): void; | ||
|
||
addAttribute(name: string, data: any): void; | ||
|
||
addPrecursorId(id: string): void; | ||
|
||
addAnnotation(key: string, value: boolean | string | number): void; | ||
|
||
addMetadata(key: string, value: any, namespace?: string): void; | ||
|
||
addSqlData(sqlData: any): void; | ||
|
||
addError(err: Error | string, remote?: boolean): void; | ||
|
||
addRemoteRequestData(req: http.ClientRequest, res: http.IncomingMessage, downstreamXRayEnabled: boolean): void; | ||
|
||
addFaultFlag(): void; | ||
|
||
addErrorFlag(): void; | ||
|
||
addThrottleFlag(): void; | ||
|
||
close(err?: Error | string | null, remote?: boolean): void; | ||
|
||
incrementCounter(additional?: number): void; | ||
|
||
decrementCounter(): void; | ||
|
||
isClosed(): boolean; | ||
|
||
flush(): void; | ||
|
||
streamSubsegments(): true | undefined; | ||
|
||
format(): string; | ||
|
||
toString(): string; | ||
|
||
toJSON(): { [key: string]: any }; | ||
} | ||
|
||
export = Subsegment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface EC2Metadata { | ||
ec2: { | ||
instance_id: string; | ||
availability_zone: string; | ||
}; | ||
} | ||
|
||
export function getData(callback: (metadata?: EC2Metadata) => void): void; | ||
|
||
export const originName: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface ECSMetadata { | ||
ecs: { | ||
container: string; | ||
}; | ||
} | ||
|
||
export function getData(callback: (metadata?: ECSMetadata) => void): void; | ||
|
||
export const originName: string; |
11 changes: 11 additions & 0 deletions
11
packages/core/lib/segments/plugins/elastic_beanstalk_plugin.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface ElasticBeanstalkMetadata { | ||
elastic_beanstalk: { | ||
environment: string; | ||
version_label: string; | ||
deployment_id: number; | ||
}; | ||
} | ||
|
||
export function getData(callback: (metadata?: ElasticBeanstalkMetadata) => void): void; | ||
|
||
export const originName: string; |
Oops, something went wrong.