﻿using System.Runtime.Remoting.Messaging;

namespace Criteo.Profiling.Tracing
{
    internal static class TraceContext
    {
        private const string TraceCallContextKey = "crto_trace";

        public static Trace Get()
        {
            return CallContext.LogicalGetData(TraceCallContextKey) as Trace;
        }

        public static void Set(Trace trace)
        {
            CallContext.LogicalSetData(TraceCallContextKey, trace);
        }

        public static void Clear()
        {
            CallContext.FreeNamedDataSlot(TraceCallContextKey);
        }
    }
}

﻿using System;
using System.Runtime.Remoting.Messaging;

namespace Criteo.Profiling.Tracing
{
    internal static class TraceContext
    {
        private const string TraceCallContextKey = "crto_trace";

        private static readonly bool IsRunningOnMono = (Type.GetType("Mono.Runtime") != null);

        public static Trace Get()
        {
            if (IsRunningOnMono) return null;

            return CallContext.LogicalGetData(TraceCallContextKey) as Trace;
        }

        public static void Set(Trace trace)
        {
            if (IsRunningOnMono) return;

            CallContext.LogicalSetData(TraceCallContextKey, trace);
        }

        public static void Clear()
        {
            if (IsRunningOnMono) return;

            CallContext.FreeNamedDataSlot(TraceCallContextKey);
        }
    }
}

Add check for Mono for LogicalCallContext
Add check for Mono for LogicalCallContext

Some projects are running an outdated Mono version which does not implement LogicalCallContext.

Change-Id: I07d90a8cd3c909c17bbd9e856816ce625379512f
