public bool ForEach(KeyValuePair <string, object> activityTag)
            {
                if (activityTag.Value == null)
                {
                    return(true);
                }

                string key = activityTag.Key;

                if (activityTag.Value is string strVal)
                {
                    PeerServiceResolver.InspectTag(ref this, key, strVal);

                    if (key == SpanAttributeConstants.StatusCodeKey)
                    {
                        if (strVal == "Error")
                        {
                            PooledList <KeyValuePair <string, object> > .Add(ref this.Tags, new KeyValuePair <string, object>("error", "true"));
                        }
                        else if (strVal == "Unset")
                        {
                            // Unset Status is not sent: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/zipkin.md#status
                            return(true);
                        }
                    }
                }
                else if (activityTag.Value is int intVal && activityTag.Key == SemanticConventions.AttributeNetPeerPort)
                {
                    PeerServiceResolver.InspectTag(ref this, key, intVal);
                }

                PooledList <KeyValuePair <string, object> > .Add(ref this.Tags, activityTag);

                return(true);
            }
Example #2
0
            public bool ForEach(KeyValuePair <string, object> activityTag)
            {
                if (activityTag.Value == null)
                {
                    return(true);
                }

                string key = activityTag.Key;

                if (activityTag.Value is string strVal)
                {
                    PeerServiceResolver.InspectTag(ref this, key, strVal);

                    if (key == SpanAttributeConstants.StatusCodeKey && strVal == "Error")
                    {
                        PooledList <KeyValuePair <string, object> > .Add(ref this.Tags, new KeyValuePair <string, object>("error", "true"));
                    }
                }
                else if (activityTag.Value is int intVal && activityTag.Key == SemanticConventions.AttributeNetPeerPort)
                {
                    PeerServiceResolver.InspectTag(ref this, key, intVal);
                }

                PooledList <KeyValuePair <string, object> > .Add(ref this.Tags, activityTag);

                return(true);
            }
Example #3
0
            public bool ForEach(KeyValuePair <string, object> activityTag)
            {
                if (activityTag.Value == null)
                {
                    return(true);
                }

                string key = activityTag.Key;

                if (activityTag.Value is string strVal)
                {
                    PeerServiceResolver.InspectTag(ref this, key, strVal);

                    if (key == SpanAttributeConstants.StatusCodeKey)
                    {
                        this.StatusCode = StatusHelper.GetStatusCodeForTagValue(strVal);

                        if (!this.StatusCode.HasValue || this.StatusCode == Trace.StatusCode.Unset)
                        {
                            // Unset Status is not sent: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/zipkin.md#status
                            return(true);
                        }

                        // Normalize status since it is user-driven.
                        activityTag = new KeyValuePair <string, object>(key, StatusHelper.GetTagValueForStatusCode(this.StatusCode.Value));
                    }
                    else if (key == SpanAttributeConstants.StatusDescriptionKey)
                    {
                        // Description is sent as `error` but only if StatusCode is Error. See: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/zipkin.md#status
                        this.StatusDescription = strVal;
                        return(true);
                    }
                    else if (key == ZipkinErrorFlagTagName)
                    {
                        // Ignore `error` tag if it exists, it will be added based on StatusCode + StatusDescription.
                        return(true);
                    }
                }
                else if (activityTag.Value is int intVal && activityTag.Key == SemanticConventions.AttributeNetPeerPort)
                {
                    PeerServiceResolver.InspectTag(ref this, key, intVal);
                }

                PooledList <KeyValuePair <string, object> > .Add(ref this.Tags, activityTag);

                return(true);
            }
            public bool ForEach(KeyValuePair <string, object> activityTag)
            {
                if (activityTag.Value == null)
                {
                    return(true);
                }

                string key = activityTag.Key;

                if (activityTag.Value is string strVal)
                {
                    PeerServiceResolver.InspectTag(ref this, key, strVal);

                    if (key == SpanAttributeConstants.StatusCodeKey)
                    {
                        StatusCode?statusCode = StatusHelper.GetStatusCodeForTagValue(strVal);
                        if (statusCode == StatusCode.Error)
                        {
                            // Error flag: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/zipkin.md#error-flag
                            PooledList <KeyValuePair <string, object> > .Add(ref this.Tags, new KeyValuePair <string, object>("error", string.Empty));
                        }
                        else if (!statusCode.HasValue || statusCode == StatusCode.Unset)
                        {
                            // Unset Status is not sent: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/zipkin.md#status
                            return(true);
                        }

                        // Normalize status since it is user-driven.
                        activityTag = new KeyValuePair <string, object>(key, StatusHelper.GetTagValueForStatusCode(statusCode.Value));
                    }
                }
                else if (activityTag.Value is int intVal && activityTag.Key == SemanticConventions.AttributeNetPeerPort)
                {
                    PeerServiceResolver.InspectTag(ref this, key, intVal);
                }

                PooledList <KeyValuePair <string, object> > .Add(ref this.Tags, activityTag);

                return(true);
            }
Example #5
0
            public bool ForEach(KeyValuePair <string, object> activityTag)
            {
                if (activityTag.Value == null)
                {
                    return(true);
                }

                string key = activityTag.Key;

                if (activityTag.Value is string strVal)
                {
                    PeerServiceResolver.InspectTag(ref this, key, strVal);
                }
                else if (activityTag.Value is int intVal && activityTag.Key == SemanticConventions.AttributeNetPeerPort)
                {
                    PeerServiceResolver.InspectTag(ref this, key, intVal);
                }

                PooledList <KeyValuePair <string, object> > .Add(ref this.Tags, activityTag);

                return(true);
            }
            public bool ForEach(KeyValuePair <string, object> activityTag)
            {
                if (activityTag.Value is Array)
                {
                    ProcessJaegerTagArray(ref this.Tags, activityTag);
                }
                else if (activityTag.Value != null)
                {
                    var key       = activityTag.Key;
                    var jaegerTag = activityTag.ToJaegerTag();
                    if (jaegerTag.VStr != null)
                    {
                        PeerServiceResolver.InspectTag(ref this, key, jaegerTag.VStr);

                        if (key == SpanAttributeConstants.StatusCodeKey)
                        {
                            StatusCode?statusCode = StatusHelper.GetStatusCodeForTagValue(jaegerTag.VStr);
                            this.StatusCode = statusCode;
                            return(true);
                        }
                        else if (key == SpanAttributeConstants.StatusDescriptionKey)
                        {
                            this.StatusDescription = jaegerTag.VStr;
                            return(true);
                        }
                    }
                    else if (jaegerTag.VLong.HasValue)
                    {
                        PeerServiceResolver.InspectTag(ref this, key, jaegerTag.VLong.Value);
                    }

                    PooledList <JaegerTag> .Add(ref this.Tags, jaegerTag);
                }

                return(true);
            }
            public bool ForEach(KeyValuePair <string, object> activityTag)
            {
                if (activityTag.Value == null)
                {
                    return(true);
                }

                var key = activityTag.Key;

                switch (key)
                {
                case SpanAttributeConstants.StatusCodeKey:
                    this.StatusCode = activityTag.Value as string;
                    return(true);

                case SpanAttributeConstants.StatusDescriptionKey:
                    this.StatusDescription = activityTag.Value as string;
                    return(true);
                }

                if (!this.Created)
                {
                    this.Tags = PooledList <OtlpCommon.KeyValue> .Create();

                    this.Created = true;
                }

                OtlpCommon.ArrayValue arrayValue;

                switch (activityTag.Value)
                {
                case string s:
                    PeerServiceResolver.InspectTag(ref this, key, s);
                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        StringValue = s
                    }));

                    break;

                case bool b:
                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        BoolValue = b
                    }));

                    break;

                case int i:
                    PeerServiceResolver.InspectTag(ref this, key, i);
                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        IntValue = i
                    }));

                    break;

                case long l:
                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        IntValue = l
                    }));

                    break;

                case double d:
                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        DoubleValue = d
                    }));

                    break;

                case int[] intArray:
                    arrayValue = new OtlpCommon.ArrayValue();
                    foreach (var item in intArray)
                    {
                        arrayValue.Values.Add(new OtlpCommon.AnyValue {
                            IntValue = item
                        });
                    }

                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        ArrayValue = arrayValue
                    }));

                    break;

                case double[] doubleArray:
                    arrayValue = new OtlpCommon.ArrayValue();
                    foreach (var item in doubleArray)
                    {
                        arrayValue.Values.Add(new OtlpCommon.AnyValue {
                            DoubleValue = item
                        });
                    }

                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        ArrayValue = arrayValue
                    }));

                    break;

                case bool[] boolArray:
                    arrayValue = new OtlpCommon.ArrayValue();
                    foreach (var item in boolArray)
                    {
                        arrayValue.Values.Add(new OtlpCommon.AnyValue {
                            BoolValue = item
                        });
                    }

                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        ArrayValue = arrayValue
                    }));

                    break;

                case string[] stringArray:
                    arrayValue = new OtlpCommon.ArrayValue();
                    foreach (var item in stringArray)
                    {
                        arrayValue.Values.Add(item == null ? new OtlpCommon.AnyValue() : new OtlpCommon.AnyValue {
                            StringValue = item
                        });
                    }

                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        ArrayValue = arrayValue
                    }));

                    break;

                case long[] longArray:
                    arrayValue = new OtlpCommon.ArrayValue();
                    foreach (var item in longArray)
                    {
                        arrayValue.Values.Add(new OtlpCommon.AnyValue {
                            IntValue = item
                        });
                    }

                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        ArrayValue = arrayValue
                    }));

                    break;

                default:
                    PooledList <OtlpCommon.KeyValue> .Add(ref this.Tags, CreateOtlpKeyValue(key, new OtlpCommon.AnyValue {
                        StringValue = activityTag.Value.ToString()
                    }));

                    break;
                }

                return(true);
            }