All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.applicationinsights.web.extensibility.initializers.WebAppNameContextInitializer Maven / Gradle / Ivy

There is a newer version: 3.5.4
Show newest version
package com.microsoft.applicationinsights.web.extensibility.initializers;

import com.microsoft.applicationinsights.common.CommonUtils;
import com.microsoft.applicationinsights.extensibility.ContextInitializer;
import com.microsoft.applicationinsights.extensibility.context.CloudContext;
import com.microsoft.applicationinsights.telemetry.TelemetryContext;
import org.apache.commons.lang3.StringUtils;

public class WebAppNameContextInitializer implements ContextInitializer {

    private String appName;

    public void setAppName(String appName) {
        this.appName = appName;
    }

    @Override
    public void initialize(TelemetryContext context) {
        if (!CommonUtils.isNullOrEmpty(appName)) {
            CloudContext cloud = context.getCloud();
            if (StringUtils.isEmpty(cloud.getRole())) {
                cloud.setRole(appName);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy