<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def process_eni_metrics( stream_eni, myips, stream, start, end, period, sample_size, resolver, sink_uri):
 """ENI flow stream processor that rollups, enhances, and indexes the stream by time period."""

    stats = Counter()
    period_counters = flow_stream_stats(myips, stream, period)
    client = InfluxDBClient.from_dsn(sink_uri)
    resource = resolver.resolve_resource(stream_eni)
    points = []

    for period in sorted(period_counters):
        pc = period_counters[period]
        pd = datetime.fromtimestamp(period)

        for t in ('inbytes', 'outbytes'):
            tpc = pc[t]
            ips = [ip for ip, _ in tpc.most_common(sample_size)]
            resolved = resolver.resolve(ips, pd - timedelta(900), pd + timedelta(900))
            logical_counter = rollup_logical(tpc, resolved, ('app', 'env'))
            for (app, env), v in logical_counter.items():
                p = {}
#                rinfo = resolved.get(ip, {})
                p['fields'] = {'Bytes': v}
                p['measurement'] = 'traffic_%s' % t
                p['time'] = datetime.fromtimestamp(period)
                p['tags'] = {
                    'Kind': resource['type'],
                    'AccountId': resource['account_id'],
                    'App': resource['app'],
                    'Env': resource['env'],
                    'ForeignApp': app,
                    'ForeignEnv': env}
                points.append(p)

        if len(points) > 2000:
            client.write_points(points)
            stats['Points'] += len(points)
            points = []

    client.write_points(points)
    stats['Points'] += len(points)
    log.info('periods:%d resource:%s points:%d',
             len(period_counters), resource, stats['Points'])
    return stats