Socket
Socket
Sign inDemoInstall

@opentelemetry/sdk-trace-base

Package Overview
Dependencies
Maintainers
4
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/sdk-trace-base - npm Package Compare versions

Comparing version 0.25.0 to 0.25.1-alpha.2

1

build/esm/config.d.ts

@@ -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;

10

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc