@opentelemetry/sdk-trace-base
Advanced tools
Comparing version 0.25.0 to 0.25.1-alpha.2
@@ -13,2 +13,3 @@ import { Sampler } from '@opentelemetry/api'; | ||
spanLimits: { | ||
attributeValueLengthLimit: number; | ||
attributeCountLimit: number; | ||
@@ -15,0 +16,0 @@ linkCountLimit: number; |
@@ -30,2 +30,3 @@ /* | ||
spanLimits: { | ||
attributeValueLengthLimit: getEnv().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, | ||
attributeCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, | ||
@@ -32,0 +33,0 @@ linkCountLimit: getEnv().OTEL_SPAN_LINK_COUNT_LIMIT, |
@@ -28,2 +28,3 @@ import * as api from '@opentelemetry/api'; | ||
private readonly _spanLimits; | ||
private readonly _attributeValueLengthLimit; | ||
/** Constructs a new Span instance. */ | ||
@@ -50,3 +51,17 @@ constructor(parentTracer: Tracer, context: Context, spanName: string, spanContext: api.SpanContext, kind: api.SpanKind, parentSpanId?: string, links?: api.Link[], startTime?: api.TimeInput); | ||
private _isSpanEnded; | ||
private _truncateToLimitUtil; | ||
/** | ||
* If the given attribute value is of type string and has more characters than given {@code attributeValueLengthLimit} then | ||
* return string with trucated to {@code attributeValueLengthLimit} characters | ||
* | ||
* If the given attribute value is array of strings then | ||
* return new array of strings with each element truncated to {@code attributeValueLengthLimit} characters | ||
* | ||
* Otherwise return same Attribute {@code value} | ||
* | ||
* @param value Attribute value | ||
* @returns truncated attribute value if required, otherwise same value | ||
*/ | ||
private _truncateToSize; | ||
} | ||
//# sourceMappingURL=Span.d.ts.map |
@@ -48,2 +48,3 @@ /* | ||
this._spanProcessor.onStart(this, context); | ||
this._attributeValueLengthLimit = this._spanLimits.attributeValueLengthLimit || 0; | ||
} | ||
@@ -69,3 +70,3 @@ Span.prototype.spanContext = function () { | ||
} | ||
this.attributes[key] = value; | ||
this.attributes[key] = this._truncateToSize(value); | ||
return this; | ||
@@ -188,2 +189,43 @@ }; | ||
}; | ||
// Utility function to truncate given value within size | ||
// for value type of string, will truncate to given limit | ||
// for type of non-string, will return same value | ||
Span.prototype._truncateToLimitUtil = function (value, limit) { | ||
if (value.length <= limit) { | ||
return value; | ||
} | ||
return value.substr(0, limit); | ||
}; | ||
/** | ||
* If the given attribute value is of type string and has more characters than given {@code attributeValueLengthLimit} then | ||
* return string with trucated to {@code attributeValueLengthLimit} characters | ||
* | ||
* If the given attribute value is array of strings then | ||
* return new array of strings with each element truncated to {@code attributeValueLengthLimit} characters | ||
* | ||
* Otherwise return same Attribute {@code value} | ||
* | ||
* @param value Attribute value | ||
* @returns truncated attribute value if required, otherwise same value | ||
*/ | ||
Span.prototype._truncateToSize = function (value) { | ||
var _this = this; | ||
var limit = this._attributeValueLengthLimit; | ||
// Check limit | ||
if (limit <= 0) { | ||
// Negative values are invalid, so do not truncate | ||
api.diag.warn("Attribute value limit must be positive, got " + limit); | ||
return value; | ||
} | ||
// String | ||
if (typeof value === 'string') { | ||
return this._truncateToLimitUtil(value, limit); | ||
} | ||
// Array of strings | ||
if (Array.isArray(value)) { | ||
return value.map(function (val) { return typeof val === 'string' ? _this._truncateToLimitUtil(val, limit) : val; }); | ||
} | ||
// Other types, no need to apply value length limit | ||
return value; | ||
}; | ||
return Span; | ||
@@ -190,0 +232,0 @@ }()); |
@@ -41,2 +41,4 @@ import { TextMapPropagator, Sampler } from '@opentelemetry/api'; | ||
export interface SpanLimits { | ||
/** attributeValueLengthLimit is maximum allowed attribute value size */ | ||
attributeValueLengthLimit?: number; | ||
/** attributeCountLimit is number of attributes per span */ | ||
@@ -43,0 +45,0 @@ attributeCountLimit?: number; |
@@ -10,2 +10,3 @@ import { TracerConfig } from './types'; | ||
spanLimits: { | ||
attributeValueLengthLimit: number; | ||
attributeCountLimit: number; | ||
@@ -12,0 +13,0 @@ linkCountLimit: number; |
@@ -13,2 +13,3 @@ import { Sampler } from '@opentelemetry/api'; | ||
spanLimits: { | ||
attributeValueLengthLimit: number; | ||
attributeCountLimit: number; | ||
@@ -15,0 +16,0 @@ linkCountLimit: number; |
@@ -33,2 +33,3 @@ "use strict"; | ||
spanLimits: { | ||
attributeValueLengthLimit: core_1.getEnv().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, | ||
attributeCountLimit: core_1.getEnv().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, | ||
@@ -35,0 +36,0 @@ linkCountLimit: core_1.getEnv().OTEL_SPAN_LINK_COUNT_LIMIT, |
@@ -28,2 +28,3 @@ import * as api from '@opentelemetry/api'; | ||
private readonly _spanLimits; | ||
private readonly _attributeValueLengthLimit; | ||
/** Constructs a new Span instance. */ | ||
@@ -50,3 +51,17 @@ constructor(parentTracer: Tracer, context: Context, spanName: string, spanContext: api.SpanContext, kind: api.SpanKind, parentSpanId?: string, links?: api.Link[], startTime?: api.TimeInput); | ||
private _isSpanEnded; | ||
private _truncateToLimitUtil; | ||
/** | ||
* If the given attribute value is of type string and has more characters than given {@code attributeValueLengthLimit} then | ||
* return string with trucated to {@code attributeValueLengthLimit} characters | ||
* | ||
* If the given attribute value is array of strings then | ||
* return new array of strings with each element truncated to {@code attributeValueLengthLimit} characters | ||
* | ||
* Otherwise return same Attribute {@code value} | ||
* | ||
* @param value Attribute value | ||
* @returns truncated attribute value if required, otherwise same value | ||
*/ | ||
private _truncateToSize; | ||
} | ||
//# sourceMappingURL=Span.d.ts.map |
@@ -49,2 +49,3 @@ "use strict"; | ||
this._spanProcessor.onStart(this, context); | ||
this._attributeValueLengthLimit = this._spanLimits.attributeValueLengthLimit || 0; | ||
} | ||
@@ -70,3 +71,3 @@ spanContext() { | ||
} | ||
this.attributes[key] = value; | ||
this.attributes[key] = this._truncateToSize(value); | ||
return this; | ||
@@ -178,4 +179,44 @@ } | ||
} | ||
// Utility function to truncate given value within size | ||
// for value type of string, will truncate to given limit | ||
// for type of non-string, will return same value | ||
_truncateToLimitUtil(value, limit) { | ||
if (value.length <= limit) { | ||
return value; | ||
} | ||
return value.substr(0, limit); | ||
} | ||
/** | ||
* If the given attribute value is of type string and has more characters than given {@code attributeValueLengthLimit} then | ||
* return string with trucated to {@code attributeValueLengthLimit} characters | ||
* | ||
* If the given attribute value is array of strings then | ||
* return new array of strings with each element truncated to {@code attributeValueLengthLimit} characters | ||
* | ||
* Otherwise return same Attribute {@code value} | ||
* | ||
* @param value Attribute value | ||
* @returns truncated attribute value if required, otherwise same value | ||
*/ | ||
_truncateToSize(value) { | ||
const limit = this._attributeValueLengthLimit; | ||
// Check limit | ||
if (limit <= 0) { | ||
// Negative values are invalid, so do not truncate | ||
api.diag.warn(`Attribute value limit must be positive, got ${limit}`); | ||
return value; | ||
} | ||
// String | ||
if (typeof value === 'string') { | ||
return this._truncateToLimitUtil(value, limit); | ||
} | ||
// Array of strings | ||
if (Array.isArray(value)) { | ||
return value.map(val => typeof val === 'string' ? this._truncateToLimitUtil(val, limit) : val); | ||
} | ||
// Other types, no need to apply value length limit | ||
return value; | ||
} | ||
} | ||
exports.Span = Span; | ||
//# sourceMappingURL=Span.js.map |
@@ -41,2 +41,4 @@ import { TextMapPropagator, Sampler } from '@opentelemetry/api'; | ||
export interface SpanLimits { | ||
/** attributeValueLengthLimit is maximum allowed attribute value size */ | ||
attributeValueLengthLimit?: number; | ||
/** attributeCountLimit is number of attributes per span */ | ||
@@ -43,0 +45,0 @@ attributeCountLimit?: number; |
@@ -10,2 +10,3 @@ import { TracerConfig } from './types'; | ||
spanLimits: { | ||
attributeValueLengthLimit: number; | ||
attributeCountLimit: number; | ||
@@ -12,0 +13,0 @@ linkCountLimit: number; |
{ | ||
"name": "@opentelemetry/sdk-trace-base", | ||
"version": "0.25.0", | ||
"version": "0.25.1-alpha.2+78a78c09", | ||
"description": "OpenTelemetry Tracing", | ||
@@ -83,8 +83,8 @@ "main": "build/src/index.js", | ||
"dependencies": { | ||
"@opentelemetry/core": "0.25.0", | ||
"@opentelemetry/resources": "0.25.0", | ||
"@opentelemetry/semantic-conventions": "0.25.0", | ||
"@opentelemetry/core": "^0.25.1-alpha.2+78a78c09", | ||
"@opentelemetry/resources": "^0.25.1-alpha.2+78a78c09", | ||
"@opentelemetry/semantic-conventions": "^0.25.0", | ||
"lodash.merge": "^4.6.2" | ||
}, | ||
"gitHead": "0ef1fc28d366b74d98b73b5d6334ffdc75342fe2" | ||
"gitHead": "78a78c093c2df24b66c47af4e037da9a6098fedb" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
238819
3966
1
+ Added@opentelemetry/core@0.25.1-alpha.23(transitive)
+ Added@opentelemetry/resources@0.25.1-alpha.23(transitive)
- Removed@opentelemetry/core@0.25.0(transitive)
- Removed@opentelemetry/resources@0.25.0(transitive)