---
schema_version: "1"
id: e079b7dcc048a72664d6ca3f1047d33008ec6c5efa747c1b93cbc4a590fae4f9
title: Context Information Injection
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-sdk/latest/context-information-injection.md
canonical_url: https://docs.mulesoft.com/mule-sdk/latest/context-information-injection
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a7984b0f7841c6774088070ad1953f71ad9f5ca54ae59666b7162cfcc249ddf6
description: MuleSoft Documentation Site
release: "1.13"
latest: true
---
---
product: Mule SDK
version: 1.13
is-latest-version: true
keywords: mule, sdk, context, inject, event, location
---

# Context Information Injection

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

To get information about the context in which an operation or source is being processed, you can add
parameters to the operation or source. The parameters do not appear in the UI, but they are injected
by the SDK into the runtime.

## Component Location

When executing an operation or using a source, you might want to have some context about the
location of the component, mostly for logging purposes. To achieve this, you can define a
`ComponentLocation` as a parameter, and it will be injected.

This examples shows how to log the component location when starting a source:

```java
@Alias("listener")
public class HttpListener extends Source<InputStream, HttpRequestAttributes> {

  private static final Logger LOGGER = getLogger(HttpListener.class);

  @Connection
  private ConnectionProvider<HttpServer> serverProvider;

  private ComponentLocation location;

  @Parameter
  private String path;

  private HttpServer server;

  @Override
  public void onStart(SourceCallback<InputStream, HttpRequestAttributes> sourceCallback) throws MuleException {
    server = serverProvider.connect();
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Starting HTTP Listener %s on path %s", location.getLocation(), path);
    }
    server.listen(path);
  }
// ...
}
```

This example shows how to log the component location in an operations (non-source) context:

```java
//ComponentLocation is added as a parameter when used in an operation
  public String sayHi(String person, String q, ComponentLocation location) {
    // ...

    System.out.println("Location: " + location.getLocation());

   // ...
  }
```

## Tracking an Event

**Available since version 1.1**

To be able to trace an event through logs, you can use a `CorrelationInfo` parameter in your
operations and source callback. This correlation info provides the event ID and correlation ID of
the event that is processed.

You simply need to add a `CorrelationInfo` parameter to your operation method or source callback.
The instance will be populated with the event information the method or callback runs.

This simplified example shows how to use `CorrelationInfo`:

```java
public class ObjectStoreOperations {
  private static final Logger LOGGER = getLogger(ObjectStoreOperations.class);
// ...
  @Throws(StoreErrorTypeProvider.class)
  public void store(String key,
                    @Content TypedValue<Serializable> value,
                    ObjectStore objectStore,
                    CorrelationInfo correlationInfo) {
      objectStore.store(key, value);
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Object stored with key: %s .The event id is: %s", key, correlationInfo.getEventId());
      }
  }
// ...
}
```
