本文整理汇总了TypeScript中dd-trace.init函数的典型用法代码示例。如果您正苦于以下问题:TypeScript init函数的具体用法?TypeScript init怎么用?TypeScript init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: init
export function init() {
const ddServicePrefix = "positron"
tracer.init({
// Setting the service name to `.undetected` so that we detect services that
// are running as part of the application, but aren't explicitly configured
// with `tracer.use`. We want to to explicitly configure services so that we
// can enforce our `.`-deliminited Service naming convention.
service: `${ddServicePrefix}.undetected`,
hostname: process.env.DATADOG_AGENT_HOSTNAME,
})
tracer.use("express", {
service: `${ddServicePrefix}`,
})
tracer.use("mongodb-core", {
service: `${ddServicePrefix}.mongodb`,
})
tracer.use("elasticsearch", {
service: `${ddServicePrefix}.elasticsearch`,
})
tracer.use("http", {
service: `${ddServicePrefix}.http`,
})
}
示例2: require
import * as ddTrace from 'dd-trace';
import SpanContext = require('dd-trace/src/opentracing/span_context');
const tracer = ddTrace.init({
service: 'MyLovelyService',
hostname: 'localhost',
port: 8126,
});
tracer
.trace('web.request', {
service: 'my_service',
childOf: new SpanContext({ traceId: 1337, spanId: 42 }),
tags: {
env: 'dev'
}
})
.then(span => {
span.setTag('my_tag', 'my_value');
span.finish();
});
示例3: require
import * as tracer from "dd-trace";
import SpanContext = require("dd-trace/src/opentracing/span_context");
tracer.init({
enabled: true,
service: "MyLovelyService",
hostname: "localhost",
port: 8126,
env: "dev",
logger: {
debug: msg => {},
error: err => {},
}
});
function useWebFrameworkPlugin(plugin: "express" | "hapi" | "koa" | "restify") {
tracer.use(plugin, {
service: "incoming-request",
headers: ["User-Agent"],
validateStatus: code => code !== 418,
});
}
tracer.use("graphql", {
depth: 1,
// Canât use spread operator here due to https://github.com/Microsoft/TypeScript/issues/10727
// tslint:disable-next-line:prefer-object-spread
variables: variables => Object.assign({}, variables, { password: "REDACTED" }),
});
tracer.use("http", {
示例4:
import ddTracer from "dd-trace"
if (process.env.DD_APM_ENABLED) {
ddTracer.init({
hostname: process.env.DD_TRACE_AGENT_HOSTNAME,
service: "force",
plugins: false,
})
ddTracer.use("express", {
// We want the root spans of MP to be labelled as just `service`
service: "force",
headers: ["User-Agent"],
})
ddTracer.use("http", {
service: `force.http-client`,
})
}
示例5: require
import * as tracer from 'dd-trace';
import SpanContext = require('dd-trace/src/opentracing/span_context');
tracer.init({
service: 'MyLovelyService',
hostname: 'localhost',
port: 8126,
logger: {
debug: msg => { },
error: err => { }
}
});
tracer
.trace('web.request', {
service: 'my_service',
childOf: new SpanContext({ traceId: 1337, spanId: 42 }), // Childof must be an instance of this type. See: https://github.com/DataDog/dd-trace-js/blob/master/src/opentracing/tracer.js#L99
tags: {
env: 'dev'
}
})
.then(span => {
span.setTag('my_tag', 'my_value');
span.finish();
});
const parentScope = tracer.scopeManager().active();
const span = tracer.startSpan('memcached', {
childOf: parentScope && parentScope.span(),
tags: {
'service.name': 'my-memcached',
示例6: require
import * as tracer from "dd-trace";
import SpanContext = require("dd-trace/src/opentracing/span_context");
tracer.init({
service: "MyLovelyService",
hostname: "localhost",
port: 8126,
logger: {
debug: msg => {},
error: err => {},
},
tags: { tracerEnv: 'dev'}
});
function useWebFrameworkPlugin(plugin: "express" | "hapi" | "koa" | "restify") {
tracer.use(plugin, {
service: "incoming-request",
headers: ["User-Agent"],
validateStatus: code => code !== 418,
});
}
tracer.use("graphql", {
depth: 1,
// Canât use spread operator here due to https://github.com/Microsoft/TypeScript/issues/10727
// tslint:disable-next-line:prefer-object-spread
variables: variables => Object.assign({}, variables, { password: "REDACTED" }),
});
tracer.use("http", {
splitByDomain: true,
示例7:
import * as ddTrace from 'dd-trace';
const tracer = ddTrace.init();
tracer
.trace('web.request', {
service: 'my_service'
})
.then(span => {
span.setTag('my_tag', 'my_value');
span.finish();
});